#!/usr/bin/env python
# -*- coding:utf-8 -*-
import Mythreadpool
from telnetlib import Telnet
import time


def MyTelnet(ip):
    tel=Telnet(ip)
    idx=tel.expect(["username:","login:"],timeout=5)
    time.sleep(5)
    tel.close()

def ippool(net):
    ip_list=[]
    for i in range(2,254):
        ip_list.append("%s.%d"%(net,i))
    return ip_list

ip_list=ippool("192.168.0")
pool=Mythreadpool.Pool(5)
requests=Mythreadpool.Requests(MyTelnet,ip_list)
for req in requests:
    pool.putRequests(req)
pool.wait()
pool.close()